<?php
class TypicalModel
{
    public function __construct()
    {
        $this->db = Yaf_Registry::get('db');
    }

    public function selectTypical($start,$everyPage)
    {
        $sql = "select * from `article_type` limit {$start},{$everyPage}";
        return $this->db->query($sql);
    }
     public function getTypicalInfo()
    {
        $sql = "select * from `article_type` ";
        return $this->db->query($sql);
    }

    public function getAllCount()
    {
        $sql="select count(*) as `rows` from `article_type` ";
        return $this->db->query($sql);
    }

    public function del($id)
    {
        $sql = "delete from article_type where article_type_id='{$id}' ";
        return $this->db->query($sql);
    }

    public function add($info)
    {
        $sql="insert into article_type(`name`,`remark`) values('{$info['name']}','{$info["remark"]}')";
        /*if(file_exists($_SERVER['DOCUMENT_ROOT'].'/caiji')){
            mkdir($_SERVER['DOCUMENT_ROOT'].'/caiji/'.$info["remark"],0777,true);
        }
        else{
            exit;
        }*/
        return $this->db->query($sql);
    }

    public function edit($info, $id)
    {
        $sql = "update `article_type` set `name`='{$info['name']}', `remark`='{$info['remark']}' WHERE `article_type_id`='{$id}'";
        return $this->db->query($sql);
    }



}